# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=modlishka
pkgver=v.1.1.1.r3.g0348d52
pkgrel=1
pkgdesc='A powerful and flexible HTTP reverse proxy.'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-proxy')
url='https://github.com/drk1wi/Modlishka'
license=('custom:unknown')
makedepends=('git' 'go')
source=("git+https://github.com/drk1wi/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd $pkgname

  GOPATH="$srcdir" go mod download
  GOPATH="$srcdir" go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-s -w" \
    -o $pkgname .

}

package() {
  cd $pkgname

  install -Dm 755 $pkgname "$pkgdir/usr/bin/$pkgname"

  install -dm 644 "$pkgdir/usr/share/$pkgname/templates"

  install -Dm 644 templates/*.json "$pkgdir/usr/share/$pkgname/templates/"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

